﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using crm_dal.Objects;


namespace crm_web.DataPages
{
    public partial class EditUser : System.Web.UI.Page
    {

        User displayUser;
        protected void Page_Init(object sender, EventArgs e)
        {
            displayUser = new User(Convert.ToInt32(HttpContext.Current.Session["Selection"]));
            txtFirstName.Text = displayUser.FirstName;
            txtLastName.Text = displayUser.LastName;
            txtLoginName.Text = displayUser.LoginName;
            chkIsAdmin.Checked = displayUser.IsAdmin;
            chkIsMgr.Checked = displayUser.IsMgr;
            chkIsCSR.Checked = displayUser.IsCSR;
            chkIsSA.Checked = displayUser.IsSA;

        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            displayUser.FirstName = txtFirstName.Text;
            displayUser.LastName = txtLastName.Text;
            displayUser.LoginName = txtLoginName.Text;
            displayUser.IsAdmin = Convert.ToBoolean(chkIsAdmin.Checked);
            displayUser.IsMgr = Convert.ToBoolean(chkIsMgr.Checked);
            displayUser.IsCSR = Convert.ToBoolean(chkIsCSR.Checked);
            displayUser.IsSA = Convert.ToBoolean(chkIsSA.Checked);
            displayUser.Update();
        }
    }
}